package com.lcke.lemon.aop;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.core.aspect.Interceptor;
import org.noear.solon.core.aspect.Invocation;

import java.lang.reflect.Method;
import java.util.Map;

//定义一个加料处理（就是个拦截处理）
@Slf4j
public class MyInterceptor implements Interceptor {

    @Override
    public Object doIntercept(Invocation inv) throws Throwable {
        Method method = inv.method().getMethod();
        String name = method.getName();
        log.info(name);
        Map<String, Object> stringObjectMap = inv.argsAsMap();
        log.info(JSONUtil.toJsonStr(stringObjectMap));

        return inv.invoke();
    }
}

